package javase_class_250908;

/**
 * ClassName: Outer2
 * Package: javase_class_250908
 * Description:
 *
 * @Author harkjeans
 * @Create 2025/9/8 19:28
 * @Version 1.0
 */
public class Outer2 {
    private String outerField = "Outer Field";

    public void someMethod() {
        final String localVar = "Local Variable"; // effectively final

        // 局部内部类
        class LocalInner {
            public void print() {
                System.out.println("Outer field: " + outerField);
                System.out.println("Local variable: " + localVar); // 只能访问final/effectively final的局部变量
            }
        }

        // 只能在someMethod方法内部使用
        LocalInner localInner = new LocalInner();
        localInner.print();
    } // 方法结束，LocalInner类的作用域也结束了
}
class Test2{
    public static void main(String[] args) {
        Outer2 o2 = new Outer2();
        o2.someMethod();
    }
}
